package com.study.thymeleaf.controller;

import java.util.HashMap;
import java.util.Map;

import com.study.thymeleaf.util.WebClientUtil;

import cn.hutool.core.util.IdUtil;

public class SendMsgController {

	
	public static void sendSms(String phone){
//	    String templateUUID = PropertiesUtil.getProperty(smsCodeMap.get(type));
//	    String smsSystemCode = getSmsSystemCode();
	    String templateUUID = "9";
	    String smsSystemCode = "1";
	    Map<String,Object> parameterMap = new HashMap<>();
	    parameterMap.put("phone", phone);
	    parameterMap.put("ip", "172.16.10.193");
	    parameterMap.put("systemCode", smsSystemCode);
	    parameterMap.put("templateId", templateUUID);
//	    String content = HttpClientUtil.post(getSmsSendUrl(), parameterMap, null);
	    String content = WebClientUtil.sendPostByJson(getSmsSendUrl(), parameterMap, null);
	    System.out.println(content);
	}
	
	/**
     * 获取短信发送接口地址
     * @return
     */
    public static String getSmsSendUrl(){
//        String smsSendUrl = request.getServletContext().getInitParameter("smsSendUrl");
        return "https://sms.laozicloud.com/sms/send";
    }
    
    public static void main(String[] args) {
//    	sendSms("18516750733");
    	sendSms1("18516750733");
	}
    
    
    public static void sendSms1(String phone) {
    	String post = WebClientUtil.sendPost("https://gate.laozicloud.com/api-auth/oauth/user/sendSms", 
    			"ignore=2zp8SIiXeF5xseF0&phone=18516750733&type=smsRegister&client-id=webApp&client-secret=webApp");
    	System.out.println(post);
    }
}
